#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int n;
    int a[100];
    int tmp;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    int z=0,zf=0,fu,zhen;
    for(int i=0;i<n;i++)
        if(a[i] == 0)
            z++;
    for(int i=0;i<n;i++)
        if(a[i] == 0){
            zf=i;
            break;
        } 
      
    fu=zf;zhen=n-1-(zf+z-1);
    if(a[n-1]==0){
        
        if(zf%2 == 0){
        printf("%d ",zf-3);
            for(int i=3;i<=zf-1;i++)
            printf("%d ",a[i]);
        printf("\n");
        }
        else{
        printf("%d ",zf-2);
        for(int i=2;i<=zf-1;i++)
            printf("%d ",a[i]);
        printf("\n");
        }
        printf("%d %d %d\n",2,a[0],a[1]);
        if(zf%2==0)
            printf("%d ",z+1);
        else
            printf("%d ",z);
        if(zf%2 == 0)
            printf("%d ",a[2]);
        for(int i=0;i<z;i++)
            printf("0 ");
        printf("\n");
    }
    else{
    
        
        if(zf%2==0){
        printf("%d ",fu-1);
            for(int i=1;i<fu;i++)
            printf("%d ",a[i]);
        printf("\n");
            }
        else{
        printf("%d ",fu);
        for(int i=0;i<fu;i++)
            printf("%d ",a[i]);
        printf("\n");
        }
        printf("%d ",zhen);
       
        for(int i=n-1;i>=n-zhen;i--)
            printf("%d ",a[i]);
        printf("\n");
        if(zf%2==0)
            printf("%d ",z+1);
        else
            printf("%d ",z);
        if(zf%2==0)
            printf("%d ",a[0]);
        for(int i=0;i<z;i++)
            printf("0 ");
        printf("\n");
    }
}